package com.lyf.os.practice.nju;

/**
 * @author LYF
 * @date 2022/7/2
 */
// 定义资源类--需要并发去操作的资源
class Resource{
    private int count=10;//数量
    // other atr..
    public synchronized void decr(){

        count--;// 资源数量减少

    }
}

public class JucDemo {

    public static void main(String[] args) {
        Resource resource = new Resource();
        new Thread(()->{resource.decr();},"a").start();
        new Thread(()->{resource.decr();},"b").start();
    }

}
